{% extends 'base.html' %}
{% load i18n %}

{% block head %}
  <script src="{{ STATIC_URL }}js/articles.js"></script>
{% endblock head %}

{% block main %}
  <ol class="breadcrumb">
    <li><a href="{% url 'articles' %}">{% trans 'Articles' %}</a></li>
    <li><a href="{% url 'drafts' %}">{% trans 'Drafts' %}</a></li>
    <li class="active">{% trans 'Edit' %}</li>
  </ol>
  <form action="{% url 'edit_article' form.instance.pk %}" method="post" role="form">
    {% csrf_token %}
    {{ form.status }}
    {% for field in form.visible_fields %}
      <div class="form-group{% if field.errors %} has-error{% endif %}">
        <label for="{{ field.label }}" class="control-label">{{ field.label }}</label>
        {% if field.label == 'Content' %}
          {% include 'markdown_editor.html' with textarea='id_content' %}
        {% endif %}
        {{ field }}
        {% if field.help_text %}
          <span class="help-block">{{ field.help_text }}</span>
        {% endif %}
        {% for error in field.errors %}
          <label class="control-label">{{ error }}</label>
        {% endfor %}
      </div>
    {% endfor %}
    <div class="form-group">
      <button type="button" class="btn btn-primary publish">{% trans 'Publish' %}</button>
      <button type="button" class="btn btn-default draft">{% trans 'Save Draft' %}</button>
      <a href="{% url 'drafts' %}" class="btn btn-default">{% trans 'Cancel' %}</a>
    </div>
  </form>
{% endblock main %}
